package com.ruoyi.system.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.RecruitmentResume;
import com.ruoyi.system.domain.Resume;
import com.ruoyi.system.model.SendRecord;
import com.ruoyi.system.service.IRecruitmentResumeService;
import com.ruoyi.system.service.IRecruitmentService;
import com.ruoyi.system.service.IResumeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 投递记录管理Controller
 *
 * @author ruoyi
 * @date 2022-11-05
 */
@Api("简历管理")
@Controller
@RequestMapping("/system/sendRecord")
public class SendRecordController extends BaseController {
    private String prefix = "system/sendRecord";

    @Resource
    private IRecruitmentResumeService recruitmentResumeService;

    @Resource
    private IResumeService resumeService;

    @Resource
    private IRecruitmentService recruitmentService;

    @ApiOperation("跳转投递记录管理列表页")
    @RequiresPermissions("system:sendRecord:view")
    @GetMapping()
    public String resume()
    {
        return prefix + "/sendRecord";
    }

    /**
     * 查询投递记录管理列表
     * @param recruitmentResume 投递记录对象
     * @return
     */
    @ApiOperation("查询投递记录管理列表")
    @RequiresPermissions("system:sendRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecruitmentResume recruitmentResume)
    {
        List<SendRecord> list = recruitmentResumeService.selectSendRecord(recruitmentResume);
        return getDataTable(list);
    }

    /**
     * 导出投递记录管理列表
     * @param recruitmentResume 投递记录对象
     * @return
     */
    @ApiOperation("导出投递记录管理列表")
    @RequiresPermissions("system:sendRecord:export")
    @Log(title = "投递记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecruitmentResume recruitmentResume)
    {
        List<RecruitmentResume> list = recruitmentResumeService.selectRecruitmentResumeList(recruitmentResume);
        ExcelUtil<RecruitmentResume> util = new ExcelUtil<RecruitmentResume>(RecruitmentResume.class);
        return util.exportExcel(list, "投递记录管理数据");
    }

    /**
     * 删除投递记录管理
     * @param ids 待删除的记录id集合
     * @return
     */
    @ApiOperation("删除投递记录管理")
    @RequiresPermissions("system:sendRecord:remove")
    @Log(title = "投递记录管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recruitmentResumeService.deleteRecruitmentResumeByRecResIds(ids));
    }
}
